package com.ws.rest;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/json/product")
public class JSONService {

	//http://localhost:8080/RESTfulExample/json/product/get
	@GET
	@Path("/get")
	@Produces("application/json")
	public Product getProductInJSON() {

		Product product = new Product();
		product.setName("iPad 3");
		product.setQty(999);
		
		return product; 

	}

	//http://localhost:8080/RESTfulExample/json/product/post
	@POST
	@Path("/post")
	@Consumes("application/json")
	@Produces("application/json")
	public Product createProductInJSON(Product product) {
		String result = "Product created : " + product;
		System.out.println(result);
//		return Response.status(201).entity(result).build();
		return product;
	}
	
}